home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / vopl / glvopl.lha / glvopl / examples / fex1.F < prev    next >
Encoding:
Text File  |  1993-10-07  |  1.5 KB  |  100 lines

  1. c
  2. c    A very simple test program for vopl.
  3. c
  4. c     This one draws a graph of y = sin(x) 0 <= x <= 2*pi
  5. c
  6.     program test1
  7. #ifdef SGI_GL
  8. #include "fgl.h"
  9. #include "fdevice.h"
  10. #else
  11. #include "fvogl.h"
  12. #include "fvodevice.h"
  13. #endif
  14.     parameter (pi = 3.14159265358979)
  15.     parameter (n = 300)
  16.  
  17.     integer *2 val
  18.     integer *2 left, right, bottom, top
  19.  
  20.     real x(n), y(n)
  21.  
  22. c
  23. c    Generate the points
  24. c
  25.     t = 0.0
  26.     dt = 2 * pi / n
  27.  
  28.     do 10 i = 1, n
  29.         x(i) = t
  30.         y(i) = sin(t)
  31.         t = t + dt
  32. 10    continue
  33.  
  34. c
  35. c    Adjust the scaling according to x and y arrays
  36. c
  37.     call adjustscale(x, n, 'x')
  38.     call adjustscale(y, n, 'y')
  39. c
  40. c    As we are now about to do some graphics we initialise VOGLE
  41. c    and clear to BLACK
  42. c
  43.     call hfont('times.r', 7)
  44.     call winope('VOPL', 4)
  45.     call qdevic(KEYBD)
  46.     call color(0)
  47.     call clear
  48. c
  49. c    Now set the color to GREEN
  50. c
  51.     call color(2)
  52.  
  53. c
  54. c    Draw the default set of axes (in GREEN)
  55. c
  56.     call drawaxes2
  57. c
  58. c    Set color to RED
  59. c
  60.     call color(1)
  61. c
  62. c    Draw the Graph
  63. c
  64.     call plot2(x, y, n)
  65. c
  66. c    Wait around a bit
  67. c
  68.     idum = qread(val)
  69. c
  70. c    Now draw a little one in the top right hand corner
  71. c    by reseting the VOGL viewport.
  72. c
  73.         call getvie(left, right, bottom, top)
  74. c
  75. c    Now assign them to integer *4 variables (thanks SGI!)
  76. c
  77.     minx = left
  78.     maxx = right
  79.     miny = bottom
  80.     maxy = top
  81.         call viewpo((minx + maxx) / 2, maxx, (maxy + miny) / 2, maxy)
  82. c
  83. c    Draw it again, but do the plot first (in BLUE) then the axes
  84. c    (in YELLOW)
  85. c
  86.     call color(4)
  87.     call plot2(x, y, n)
  88.     call color(3)
  89.     call drawaxes2
  90. c
  91. c    Hang around again
  92. c
  93.     idum = qread(val)
  94. c
  95. c    Bugger off...
  96. c
  97.  
  98.     call gexit
  99.     end
  100.